Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Controller Script Error Reporting #2588

Merged
merged 22 commits into from
Apr 18, 2020

Conversation

Holzhaus
Copy link
Member

If a controller script contains syntax errors or cannot be opened (e.g. due to permission errors), we don't show a popup when trying to initalize it. The user will often only notice it when pressing a button when Mixxx fails to invoke MyController.someFunction, not instantly when loading the script. This could even happen in the middle of a set, e.g. when using something like a Korg nanoKONTROL for FX only. This behaviour also makes it unnecessarily hard for mapping developers to debug issues, because the actual error message is not shown, just a meaningless error that was caused by the failed script load.

This enables the error reporting on failed script load, and also uninitializes the script engine in that case. This means that a single error dialog will be shown when the script load fails, but subsequent button presses on the controller will do nothing and not open a popup every time. Auto-reloading the script when it changes (or the permissions are changed) will still work fine.

I also modified the error messages a bit. All error dialogs should now show the controller name (in case multiple controllers are connected). Script filenames and error messages from the OS or the script engine were moved into the "Details" section of the error messages, because in most cases they are not interesting to a regular user (failures when opening the file is a special case, but I moved the filename to the details part anyway for consistency).

@Holzhaus
Copy link
Member Author

I don't know if this should go into 2.3 but IMHO the current behaviour is confusing and a major annoyance when writing controller mappings.

@ferranpujolcamins
Copy link
Contributor

ferranpujolcamins commented Mar 22, 2020

This overlaps with #1795 (comment)

Which we'll release with 2.4 and we'll merge as soon as the 2.3 branch is cut.

Please have a look at my branch and rebase there if you think this is still relevant.

@Holzhaus
Copy link
Member Author

Nice!

I think we should merge this PR for 2.3 and just replace it with your code in 2.4. It will be at least half a year between the 2.3 and 2.4 releases and I think controller mapping creators would really appreciate getting notified where exactly the syntax error is.

@Holzhaus Holzhaus added this to the 2.3.0 milestone Mar 22, 2020
@Be-ing Be-ing modified the milestones: 2.3.0, 2.4.0 Mar 24, 2020
@Holzhaus Holzhaus removed this from the 2.4.0 milestone Mar 26, 2020
@Holzhaus Holzhaus added this to the 2.3.0 milestone Apr 2, 2020
@Be-ing
Copy link
Contributor

Be-ing commented Apr 7, 2020

I'm okay with merging this for 2.3 if you agree to take care of merge conflicts with #1795, @Holzhaus. I will probably not review this before the initial 2.3 beta release.

@Holzhaus
Copy link
Member Author

Holzhaus commented Apr 8, 2020

Solving merge conflicts is not exactly my favorite activity, but someone gotta do it eventually. I'll do my best.

Previously the backtrace was only added to the error details if
the `--controllerDebug` flag was passed to Mixxx. Since the error
details are only displayed if the user explicitly uncollapsed the
"Details" expander and non-technical users won't be able to make use of
the engine's error message and line number anyway, we can just show it
unconditionally. This might even result in more helpful bug reports.
@Holzhaus
Copy link
Member Author

Ok, this is now in a good state IMHO. This should vastly improve DX for controller mapping developers. Please review.

@Holzhaus
Copy link
Member Author

Anything else to do here?

Copy link
Contributor

@Be-ing Be-ing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I save a script with a syntax error, then fix the error and save again, the script is not reloaded until I restart Mixxx. I see this in the log:

Critical [Controller]: DEBUG ASSERT: "m_pEngine != nullptr" in function QScriptValue ControllerEngine::wrapFunctionCode(const QString &, int) at /home/be/sw/mixxx/src/controllers/controllerengine.cpp:114

src/controllers/controllerengine.cpp Outdated Show resolved Hide resolved
src/controllers/controllerengine.cpp Outdated Show resolved Hide resolved
@Holzhaus
Copy link
Member Author

When I save a script with a syntax error, then fix the error and save again, the script is not reloaded until I restart Mixxx. I see this in the log:

Critical [Controller]: DEBUG ASSERT: "m_pEngine != nullptr" in function QScriptValue ControllerEngine::wrapFunctionCode(const QString &, int) at /home/be/sw/mixxx/src/controllers/controllerengine.cpp:114

Fixed. The problem was that not all errors were handled equally. We now also catch errors when calling the controller's init function and shut down the script engine when that fails. Otherwise you can get hundreds of script error popups on every slider move.

@Holzhaus Holzhaus requested a review from Be-ing April 16, 2020 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants